package com.khh.garment.basedata;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.khh.base.common.config.BaseCommonConfigUnit;
import com.khh.garment.basedata.context.BusinessbasedataContext;

public class BusinessbasedataConfiguration {
	
	private static BusinessbasedataConfiguration _instance;
	
	private static Logger logger = Logger.getLogger(BusinessbasedataConfiguration.class);
	
	private static String[] springContextXml;
	
	private ApplicationContext cxt;
	
	private BusinessbasedataConfiguration(){
		logger.debug("Welcome to basedata !");
	}
	
	public static BusinessbasedataConfiguration getInstance(){
	
		if(null == _instance){
			
			logger.debug("creating basedata configuration.");
			
			_instance = new BusinessbasedataConfiguration();

			String springConfig = BaseCommonConfigUnit.getInstance().getProperty("business-pos-basedata.spring.config");

			springContextXml = springConfig.split(",");

			// ����Spring
			ApplicationContext cxt = new ClassPathXmlApplicationContext(springContextXml);

			_instance.setCxt(cxt);
		}

		return _instance;
	}

	public ApplicationContext getCxt() {
		return cxt;
	}

	public void setCxt(ApplicationContext cxt) {
		this.cxt = cxt;
	}
	
	
	public BusinessbasedataContext getBusinessbasedataContext(){
		
		String beanid = BaseCommonConfigUnit.getInstance().getProperty(	"business-pos-basedata.context.spring.beanid");
		
		return (BusinessbasedataContext) this.cxt.getBean(beanid);
	}



}
